import axios from 'axios'
import Config from './config'
// import { Message } from 'element-ui'

const service = axios.create({
  baseURL: Config.baseUrl,
  timeout: 60000
})

service.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8'

// request拦截器
service.interceptors.request.use(
  config => {
    
    return config
  },
  error => {
    Promise.resolve(error)
  }
)

// respone拦截器
service.interceptors.response.use(
  response => {
    if (response.data.errorcode != 200) {
      //console.log(response.config.url)
    }
    return response.data.data
  },
  error => {
    // do something 拦截响应
    return Promise.reject(error)
  }
)

export default service